package com.heima.feigns;

import com.heima.config.HeimaFeignAutoConfiguration;
import com.heima.feigns.fallback.WemediaFeignFallback;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.media.pojos.WmUser;
import com.heima.model.wmmedia.pojos.WmNews;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

@FeignClient(
        value = "leadnews-wemedia",
        fallbackFactory = WemediaFeignFallback.class,
        configuration = HeimaFeignAutoConfiguration.class
)
public interface WemediaFeign {

    //保存自媒体用户
    @PostMapping("/api/v1/user/save")
    ResponseResult<WmUser> save(@RequestBody WmUser wmUser);

    //根据用户名查询自媒体用户
    @GetMapping("/api/v1/user/findByName/{name}")
    ResponseResult<WmUser> findByName(@PathVariable("name") String name);

    //根据id查询文章
    @GetMapping("/api/v1/news/one/{id}")
    @ApiOperation("根据id查询文章")
    ResponseResult<WmNews> findWmNewsById(@PathVariable("id") Integer id);

    //根据文章id修改文章
    @PutMapping("/api/v1/news/update")
    ResponseResult<WmNews> updateWmNews(@RequestBody WmNews wmNews);

}